<?php
/**
 * Created by PhpStorm.
 * User: yys
 * Date: 2016/12/2
 * Time: 14:00
 */

namespace App\Services\CrowdService;


use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class CrowdTool
{
    /***
     * 人群ID是不是可用的
     * @param $crowd_id
     * @return bool
     */
    public static function crowdExistByCrowdId($crowd_id){
        if(empty($crowd_id)){
            return false;
        }
        $num=DB::table('crowds')->where(array('id'=>$crowd_id,'state'=>1))
            ->count();
        return ($num==0)?false:true;
    }

    /***
     * 获取人群名
     * @param $crowd_id
     * @return string
     */
    public static function crowdNameByCrowdId($crowd_id){
        if(empty($crowd_id)){
            return '';
        }
        $crowd_name=DB::table('crowds')->where(array('id'=>$crowd_id,'state'=>1))
            ->value('crowd_name');
        return empty($crowd_name)?'':$crowd_name;
    }
}